<?php

namespace app\common\model\mall;

use think\Db;
use think\Model;


class GoodsEvaluate extends Model
{
    // 表名
    protected $name = 'litestore_goods_evaluate';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [];

    const STATUS_HIDDEN = 0;

    const STATUS_NORMAL = 1;

    const IS_ANONYMOUS_NO = 0;

    const IS_ANONYMOUS_YES = 1;

    public function getAvatarAttr($value)
    {
        return cdnurl($value, true);
    }

    public function getImagesAttr($value)
    {
        if ($value) {
            $images = explode(',', $value);
            foreach ($images as $k => $v) {
                $images[$k] = cdnurl($v, true);
            }

            return $images;
        } else {
            return [];
        }
    }

    public function getCreatetimeAttr($value)
    {
        return $value ? date('Y-m-d', $value) : '';
    }
}
